import http from '@/utils/http'

const BASE_URL = '/testing/planJobLog'

export interface PlanJobLogResp {
  id: string
  planJobId: string
  planJobName: string
  executeTime: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface PlanJobLogDetailResp {
  id: string
  planJobId: string
  planJobName: string
  executeTime: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface PlanJobLogQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface PlanJobLogPageQuery extends PlanJobLogQuery, PageQuery {}

/** @desc 查询计划任务日志列表 */
export function listPlanJobLog(query: PlanJobLogPageQuery) {
  return http.get<PageRes<PlanJobLogResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询计划任务日志详情 */
export function getPlanJobLog(id: string) {
  return http.get<PlanJobLogDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增计划任务日志 */
export function addPlanJobLog(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改计划任务日志 */
export function updatePlanJobLog(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除计划任务日志 */
export function deletePlanJobLog(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出计划任务日志 */
export function exportPlanJobLog(query: PlanJobLogQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
